# Maintainer: David Runge <dvzrv@archlinux.org>
# Contributor: Ray Rashif <schiv@archlinux.org>
# Contributor: svoufff <svoufff at gmail dot com>
# Contributor: Shinlun Hsieh <yngwiexx@yahoo.com.tw>

pkgname=gigedit
pkgver=1.2.0
pkgrel=2
pkgdesc="Gigasampler instrument editor"
arch=(loong64 x86_64)
url="https://www.linuxsampler.org/"
license=(GPL2)
groups=(pro-audio)
depends=(
  atkmm libatkmm-1.6.so
  cairomm libcairomm-1.0.so
  gcc-libs
  glib2 libgobject-2.0.so libglib-2.0.so
  glibc
  glibmm libglibmm-2.4.so
  gtk3 libgtk-3.so
  gtkmm3 libgtkmm-3.0.so
  libgig libgig.so
  libsigc++ libsigc-2.0.so
  libsndfile libsndfile.so
  linuxsampler liblinuxsampler.so
  pangomm libpangomm-1.4.so
)
makedepends=(
  docbook-xsl
  gendesk
  intltool
  libxslt
)
provides=(libgigedit.so)
source=(
  https://download.linuxsampler.org/packages/$pkgname-$pkgver.tar.bz2
  $pkgname-1.2.0-libdir.patch
  $pkgname-1.2.0-redeclare.patch
)
sha512sums=('b991a5193af34be70db6eb8c18fc58e01b822b6997bfc6c3ee06eca42f57375d341316e8abc594824668c7cb916b0643a1ee1b5c34426bf3ec5e202dfc565c8f'
            'd701ee5fb013c08f3f9bb9a85464c82aaa1200ca14f8876dfd5d4835f41c1325728c07279528fb22737d79e41b33f931628637c62458e5f49aaa77f6b5dd5fe9'
            '289ad93f820da7cbd48387ea68945285297abbef33794dc2b24cc256c6384ce7ff1a1d9462cf7d37e1cffc5ddaadf52f421d904baea6d6f5db3acfe29aff445e')
b2sums=('049e4c60b345c192255669a71588df1e2905590f95351d8a79134b210d03087ac9cc33f12cbf2e38208b95ad452f299c78877632989cd914d98a05c5967087d5'
        'c752d259e42c47bfd4e819daee271a565dbd30aa5806151be028eb333ec22f40b862529fb40c69fc14f5cd455efc52d43c959501512dd72ad71b48527e7fee3c'
        '7f3f89fdccab17ac73da63467d039ea608b4e0df2f598a9ca08f7560802207399b184f98f59cfa5881f26c000ce69797236b76659b85dd5cd49766324cf70638')

prepare() {
  # generate XDG desktop file
  gendesk -n \
          --pkgname "$pkgname" \
          --name "$pkgname" \
          --genericname "Instrument Editor" \
          --categories "AudioVideo;Audio"

  # install shared object to global namespace, so no ld.so.conf is required
  patch -Np1 -d $pkgname-$pkgver -i ../$pkgname-1.2.0-libdir.patch
  # do not extend the pango namespace (breaks the build)
  patch -Np1 -d $pkgname-$pkgver -i ../$pkgname-1.2.0-redeclare.patch
}

build() {
  cd $pkgname-$pkgver
  ./configure --prefix=/usr
  # prevent excessive overlinking due to libtool
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}

package() {
  make DESTDIR="$pkgdir" install -C $pkgname-$pkgver
  install -vDm 644 $pkgname.desktop -t "$pkgdir/usr/share/applications/"
  install -vDm 644 $pkgname-$pkgver/{AUTHORS,ChangeLog,NEWS,README} -t "$pkgdir/usr/share/doc/$pkgname/"
}

# vim:set ts=2 sw=2 et:
